/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package web.example.client;

import web.app.client.AppConfig;
import web.app.client.AppController;
import web.app.client.AppEvents;
import web.app.client.security.AuthController;
import web.app.client.security.AuthEvents;
import web.dynamic.client.DynamicModule;
import web.mail.client.MailModule;

import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.google.gwt.core.client.EntryPoint;


/**
 * 
 * @author michael
 */
public class Main extends Controller implements EntryPoint {

	public void onModuleLoad() {
		
		//AppConfig.addModule( new MailModule() );
		AppConfig.addModule( new DynamicModule() );
		
		Dispatcher.get().addController(this);
		registerEventTypes(AuthEvents.AuthSuccess);
		Dispatcher.get().addController(new AuthController());

		Dispatcher.forwardEvent(AuthEvents.AuthRequired);

		GXT.hideLoadingPanel("loading");
	}

	public void handleEvent(AppEvent e) {
		Dispatcher.get().addController(new AppController());

		Dispatcher.forwardEvent(AppEvents.Init);

		Dispatcher.get().removeController(this);
	}

}
